package com.gzh.teaching.model.vo;

import com.gzh.core.dao.po.QuestionEntity;
import com.gzh.core.util.StringUtils;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @Author guanzh
 * @Date 2022/1/24 17:09
 * @Description
 */
@Setter
@Getter
@ToString
@NoArgsConstructor
public class MultipleVo {
    private String name;

    private List<String> answerList;

    private String selectA;

    private String selectB;

    private String selectC;

    private String selectD;

    private String analyze;

    public MultipleVo(QuestionEntity t) {
        this.name = t.getQuestionName();
        this.answerList = Arrays.asList(t.getAnswer().split(","));
        this.selectA = t.getSelectA();
        this.selectB = t.getSelectB();
        this.selectC = t.getSelectC();
        this.selectD = t.getSelectD();
        this.analyze = t.getAnalyzeText();
    }

    public QuestionEntity toEntity(Integer finalWorkId){
        QuestionEntity questionEntity = new QuestionEntity();
        questionEntity.setQuestionName(this.name);
        questionEntity.setAnswer(StringUtils.listToString(this.answerList));
        questionEntity.setSelectA(this.selectA);
        questionEntity.setSelectB(this.selectB);
        questionEntity.setSelectC(this.selectC);
        questionEntity.setSelectD(this.selectD);
        questionEntity.setAnalyzeText(this.analyze);
        questionEntity.setQuestionType(2);
        questionEntity.setWorkId(finalWorkId);
        return questionEntity;
    }
}
